package com.xuan.controller;

import com.xuan.api.AccountRemoteApi;
import com.xuan.model.entity.User;
import com.xuan.model.respons.ResultBody;
import com.xuan.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@RestController
@RequestMapping("/account")
public class AccountController implements AccountRemoteApi {

    @Autowired
    private AccountService accountService;

    @PostMapping("/login")
    public Map login(User user){

        return accountService.login(user);
    }

    @GetMapping("/findOne")
    public User findOne(@RequestParam("username") String username) {
        return accountService.findOne(username);
    }

    @PostMapping("/update")
    public ResultBody updateRoles(User user) {
        return accountService.updateRoles(user);
    }
}
